package cn.kgc.javaweb.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * @author: mosin
 * @version: v1.0  2022/11/6
 */
@WebListener
public class ApplicationListener implements ServletContextListener {

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        //获取项目的虚拟路径
        String contextPath = sce.getServletContext().getContextPath();
        sce.getServletContext().setAttribute("bp", contextPath);
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {

    }
}
